package com.lphl.pet.activity;

import com.lphl.pet.R;
import com.lphl.pet.receiver.BatteryReceiver;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

public class UpDataActivity extends Activity implements OnClickListener {

	private BatteryReceiver receiver;
	private ImageView iv_back;
	private TextView tv_baterry;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_update);
		
		initView();
	}
	
	private void initView() {
		iv_back = (ImageView) findViewById(R.id.iv_back);
		tv_baterry = (TextView) findViewById(R.id.tv_baterry);
		
		iv_back.setOnClickListener(this);
		tv_baterry.setOnClickListener(this);
	}

	@Override
	protected void onResume() {
		super.onResume();
        // 1. 检查手机的电量是否充足
        // 2. 检查设备信息是否稳定

        //注册一个接受广播类型

        receiver = new BatteryReceiver();
        registerReceiver(receiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));  
		
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		unregisterReceiver(receiver);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.iv_back:
			this.finish();
			break;

		case R.id.tv_baterry:
			
			break;
			
		default:
			break;
		}
	}
}
